      ***
      * IDENTIFICACION DEL PROGRAMA
      ***
       IDENTIFICATION DIVISION.
       PROGRAM-ID. CARGARINDEXADOS.
      
      ***
      * DIVISION DE ENTORNO
      * DEFINO LOS ARCHIVOS QUE VOY A UTILIZAR.
      ***
       ENVIRONMENT DIVISION.
      
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
      *    Archivos Indexados   
           SELECT ALQUILERES ASSIGN TO DISK "ALQUILERES.DAT" 
                ACCESS MODE IS DYNAMIC ORGANIZATION IS INDEXED
           		RECORD KEY IS CLAVE-ALQUILER
           		FILE STATUS IS FS-ALQUILERES.
                  		
           SELECT CHOFERES ASSIGN TO DISK "CHOFERES.DAT"
           		ACCESS MODE IS DYNAMIC ORGANIZATION IS INDEXED
           		RECORD KEY IS CLAVE-CHOFER
           		FILE STATUS IS FS-CHOFERES.
           		
           SELECT CLIENTES ASSIGN TO DISK "CLIENTES.DAT"
           		ACCESS MODE IS DYNAMIC ORGANIZATION IS INDEXED
           		ALTERNATE RECORD KEY IS CLAVE-CLIENTE-ALT
           		RECORD KEY IS CLAVE-CLIENTE-PRI
           		FILE STATUS IS FS-CLIENTES.
                
      *    Archivos Secuenciales
           SELECT SALQUILERES ASSIGN TO DISK "ALQUILERES.TXT" 
                ORGANIZATION IS LINE SEQUENTIAL
                ACCESS MODE IS SEQUENTIAL
           		FILE STATUS IS FS-SALQUILERES.
                  		
           SELECT SCHOFERES ASSIGN TO DISK "CHOFERES.TXT"
                ORGANIZATION IS LINE SEQUENTIAL
           		ACCESS MODE IS SEQUENTIAL
           		FILE STATUS IS FS-SCHOFERES.
           		
           SELECT SCLIENTES ASSIGN TO DISK "CLIENTES.TXT"
                ORGANIZATION IS LINE SEQUENTIAL
           		ACCESS MODE IS SEQUENTIAL
           		FILE STATUS IS FS-SCLIENTES.                
                 
      ***
      * DIVISION DE DATOS
      ***
       DATA DIVISION.
       FILE SECTION.
       FD ALQUILERES LABEL RECORD IS STANDARD.
       01 REG-ALQUILER.
           03 CLAVE-ALQUILER.
      	       05 ALQ-PATENTE PIC X(6).
               05 ALQ-FECHA   PIC 9(8).
           03 ALQ-TIPO-DOC PIC X.
           03 ALQ-NRO-DOC  PIC X(20).
           03 ALQ-IMPORTE PIC 9(4)V99.
           03 ALQ-CHOFER PIC X(7).
           03 ALQ-ESTADO PIC X.
       	   
       FD CHOFERES LABEL RECORD IS STANDARD.
       01 REG-CHOFER.
           03 CLAVE-CHOFER.
               05 CHOF-NRO-LEGAJO PIC X(7).
               05 CHOF-FECHA-DESDE PIC 9(8).
           03 CHOF-FECHA-HASTA PIC 9(8).
           03 CHOF-TURNO PIC X.
           
       FD CLIENTES LABEL RECORD IS STANDARD.
       01 REG-CLIENTE.
           03 CLAVE-CLIENTE-PRI.
               05 CLI-NUMERO PIC X(8).
           03 CLI-FEC-ALTA PIC 9(8).
           03 CLI-TELEFONO PIC X(20).
           03 CLI-DIRECCION PIC X(30).
           03 CLAVE-CLIENTE-ALT.
               05 CLI-DOCUMENTO PIC X(20).

       FD SALQUILERES LABEL RECORD IS STANDARD.
       01 REG-SALQUILER.
           03 SCLAVE-ALQUILER.
      	       05 SALQ-PATENTE PIC X(6).
               05 SALQ-FECHA   PIC 9(8).
           03 SALQ-TIPO-DOC PIC X.
           03 SALQ-NRO-DOC  PIC X(20).
           03 SALQ-IMPORTE PIC 9(4)V99.
           03 SALQ-CHOFER PIC X(7).
           03 SALQ-ESTADO PIC X.
       	   
       FD SCHOFERES LABEL RECORD IS STANDARD.
       01 REG-SCHOFER.
           03 SCLAVE-CHOFER.
               05 SCHOF-NRO-LEGAJO PIC X(7).
               05 SCHOF-FECHA-DESDE PIC 9(8).
           03 SCHOF-FECHA-HASTA PIC 9(8).
           03 SCHOF-TURNO PIC X.
           
       FD SCLIENTES LABEL RECORD IS STANDARD.
       01 REG-SCLIENTE.
           03 SCLAVE-CLIENTE-PRI.
               05 SCLI-NUMERO PIC X(8).
           03 SCLI-FEC-ALTA PIC 9(8).
           03 SCLI-TELEFONO PIC X(20).
           03 SCLI-DIRECCION PIC X(30).           
           03 SCLAVE-CLIENTE-ALT.
               05 SCLI-DOCUMENTO PIC X(20).
       
       WORKING-STORAGE SECTION. 
       
       01 FS-ALQUILERES PIC X(2). 
       01 FS-CHOFERES   PIC X(2).
       01 FS-CLIENTES   PIC X(2).

       01 FS-SALQUILERES PIC X(2). 
       01 FS-SCHOFERES   PIC X(2).
       01 FS-SCLIENTES   PIC X(2).       
                
       01 EOF-ALQUILERES PIC X VALUE "N".
       01 EOF-CHOFERES   PIC X VALUE "N".
       01 EOF-CLIENTES   PIC X VALUE "N".
       
       
      ***
      * DIVISION DEL PROGRAMA
      ***
       PROCEDURE DIVISION.
       	PROGRAMA.
       	DISPLAY "Inicio CARGAR INDEXADOS !".
       	PERFORM INICIO.
       	
        READ SALQUILERES.
        PERFORM
         UNTIL FS-SALQUILERES <> 00
      *      DISPLAY "CARGANDO ALQUILER !" END-DISPLAY
            DISPLAY "PATENTE     = " SALQ-PATENTE  END-DISPLAY
            DISPLAY "FECHA       = " SALQ-FECHA  END-DISPLAY
            DISPLAY "TIPO DOC    = " SALQ-TIPO-DOC  END-DISPLAY
            DISPLAY "DOCUMENTO   = " SALQ-NRO-DOC  END-DISPLAY
            DISPLAY "IMPORTE     = " SALQ-IMPORTE  END-DISPLAY
            DISPLAY "CHOFER      = " SALQ-CHOFER  END-DISPLAY
            DISPLAY "ESTADO      = " SALQ-ESTADO  END-DISPLAY
            WRITE REG-ALQUILER FROM REG-SALQUILER
            READ SALQUILERES
        END-PERFORM.
        
        READ SCHOFERES.
        PERFORM
         UNTIL FS-SCHOFERES <> 00
      *      DISPLAY "CARGANDO CHOFER !" END-DISPLAY
            WRITE REG-CHOFER FROM REG-SCHOFER
            READ SCHOFERES
        END-PERFORM.
        
        READ SCLIENTES.
        PERFORM
         UNTIL FS-SCLIENTES <> 00
      *      DISPLAY "CARGANDO CLIENTE !" END-DISPLAY
            WRITE REG-CLIENTE FROM REG-SCLIENTE
            DISPLAY "NUMERO      = " SCLI-NUMERO  END-DISPLAY
            DISPLAY "FECHA ALTA  = " SCLI-FEC-ALTA  END-DISPLAY
            DISPLAY "TELEFONO    = " SCLI-TELEFONO  END-DISPLAY
            DISPLAY "DIRECCION   = " SCLI-DIRECCION  END-DISPLAY
            DISPLAY "DOCUMENTO   = " SCLI-DOCUMENTO  END-DISPLAY
            READ SCLIENTES
        END-PERFORM.        

        DISPLAY "
        LEYENDO ALQUILERES.DAT !
        " END-DISPLAY.
        SET REG-ALQUILER TO LOW-VALUE.
        START ALQUILERES KEY IS  NOT < CLAVE-ALQUILER.
        READ ALQUILERES NEXT RECORD        
        PERFORM
         UNTIL FS-ALQUILERES <> 00
            DISPLAY REG-ALQUILER END-DISPLAY
            DISPLAY "PATENTE     = " ALQ-PATENTE  END-DISPLAY
            DISPLAY "FECHA       = " ALQ-FECHA  END-DISPLAY
            DISPLAY "TIPO DOC    = " ALQ-TIPO-DOC  END-DISPLAY
            DISPLAY "DOCUMENTO   = " ALQ-NRO-DOC  END-DISPLAY
            DISPLAY "IMPORTE     = " ALQ-IMPORTE  END-DISPLAY
            DISPLAY "CHOFER      = " ALQ-CHOFER  END-DISPLAY
            DISPLAY "ESTADO      = " ALQ-ESTADO  END-DISPLAY
            READ ALQUILERES NEXT RECORD
        END-PERFORM.

        DISPLAY "
        LEYENDO CHOFERES.DAT !
        " END-DISPLAY.
        SET CLAVE-CHOFER TO LOW-VALUE.
        START CHOFERES KEY IS  NOT < CLAVE-CHOFER.
        READ CHOFERES NEXT RECORD
        PERFORM
         UNTIL FS-CHOFERES <> 00
            DISPLAY REG-CHOFER
            READ CHOFERES NEXT RECORD
        END-PERFORM.
        
        DISPLAY "
        LEYENDO CLIENTES.DAT !
        " END-DISPLAY.
        SET REG-CLIENTE TO LOW-VALUE.
        START CLIENTES KEY IS  NOT < CLAVE-CLIENTE-PRI.
        READ CLIENTES NEXT RECORD        
        PERFORM
         UNTIL FS-CLIENTES <> 00
            DISPLAY REG-CLIENTE END-DISPLAY
            DISPLAY "NUMERO      = " CLI-NUMERO  END-DISPLAY
            DISPLAY "FECHA ALTA  = " CLI-FEC-ALTA  END-DISPLAY
            DISPLAY "TELEFONO    = " CLI-TELEFONO  END-DISPLAY
            DISPLAY "DIRECCION   = " CLI-DIRECCION  END-DISPLAY
            DISPLAY "DOCUMENTO   = " CLI-DOCUMENTO  END-DISPLAY
            READ CLIENTES NEXT RECORD
        END-PERFORM.                
      
       	PERFORM FIN.
       	DISPLAY "Fin del programa!".
       	STOP RUN.
       	
       	INICIO.
           OPEN I-O ALQUILERES.
           OPEN I-O CHOFERES.
           OPEN I-O CLIENTES.  		
           OPEN INPUT SALQUILERES.
           OPEN INPUT SCHOFERES.
           OPEN INPUT SCLIENTES.  	
           
        FIN.
           CLOSE ALQUILERES.
           CLOSE CHOFERES.
           CLOSE CLIENTES.   
           CLOSE SALQUILERES.
           CLOSE SCHOFERES.
           CLOSE SCLIENTES.
           
